﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Resources;

namespace Tester
{
    public partial class MainPage : UserControl
    {
        public int i = 0;

        public MainPage()
        {
            InitializeComponent();
        }

        private void SetAndStartClock(object sender, EventArgs e)
        {
            // The current date and time.
            System.DateTime currentDate = DateTime.Now;

            // Find the appropriate angle (in degrees) for the hour hand
            // based on the current time.
            double hourangle = (((float)currentDate.Hour) / 12) * 360 + currentDate.Minute / 2;


            // The same as for the minute angle.
            double minangle = (((float)currentDate.Minute) / 60) * 360;

            // The same for the second angle.
            double secangle = (((float)currentDate.Second) / 60) * 360;

            // Set the beginning of the animation (From property) to the angle 
            // corresponging to the current time.
            hourAnimation.From = hourangle;

            // Set the end of the animation (To property)to the angle 
            // corresponding to the current time PLUS 360 degrees. Thus, the
            // animation will end after the clock hand moves around the clock 
            // once. Note: The RepeatBehavior property of the animation is set
            // to "Forever" so the animation will begin again as soon as it completes.
            hourAnimation.To = hourangle + 360;

            // Same as with the hour animation.
            minuteAnimation.From = minangle;
            minuteAnimation.To = minangle + 360;

            // Same as with the hour animation.
            secondAnimation.From = secangle;
            secondAnimation.To = secangle + 360;

            // Start the storyboard.
            ClockEarWorm.Begin();


        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (i == 0)
            {
                i = 1;
                ClockEarWorm.Pause();
            }
            else if (i == 1)
            {
                i = 0;
                ClockEarWorm.Resume();
            }
        }


    }

}
